var _Page;

function _defineProperty(e, t, a) {
  return t in e ? Object.defineProperty(e, t, {
    value: a,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = a, e;
}

var app = getApp(),
  siteinfo = require("../../../siteinfo.js"),
  imgArray1 = [];

Page((_defineProperty(_Page = {
    data: {
      length: 0,
      star: 0,
      starMap: [
        '非常差',
        '差',
        '一般',
        '好',
        '非常好',
      ],
      url: wx.getStorageSync("url")
    },
    myStarChoose(e) {
      let star = parseInt(e.currentTarget.dataset.star) || 0;
      this.setData({
        star: star,
      });
      // console.log(star);
    },
    onLoad: function(e) {
      var t = this;
      console.log(e)
      wx.setNavigationBarColor({
        frontColor: '#000000',
        backgroundColor: '#ffffff'
      });
      t.setData({
        seller_id: e.seller_id,
        order_id: e.order_id,
        order_sn: e.order_sn
      }), app.getUserInfo(function(e) {
        console.log(e), t.setData({
          user_id: e.id,
          url: wx.getStorageSync("url")
        });
      });
    },
    textarea: function(e) {
      console.log(e);
      var t = e.detail.cursor;
      "" != e.detail.value && this.setData({
        length: t,
        value: e.detail.value
      });
    },
    submit: function(e) {
      this.data.value;
    },
    img_array: function(e) {
      var a = this;
      if (9 <= imgArray1.length) wx.showModal({
        title: "",
        content: "最多上传9张图片"
      });
      else {
        siteinfo.siteroot;
        var t = 9 - imgArray1.length;
        wx.chooseImage({
          count: t,
          sizeType: ["compressed"],
          sourceType: ["album", "camera"],
          success: function(e) {
            wx.showToast({
              icon: "loading",
              title: "正在上传"
            });
            var t = e.tempFilePaths;
            console.log('选择好了图片');
            console.log(t);
            a.uploadimg({
              url: siteinfo.siteroot + "?i=" + siteinfo.uniacid + "&c=entry&a=wxapp&do=Upload&m=zh_jdgjb",
              path: t
            });
          }
        });
      }
    },
    uploadimg: function(e) {
      console.log(e);
      var t = this,
        a = e.i ? e.i : 0,
        i = e.success ? e.success : 0,
        o = e.fail ? e.fail : 0;
      wx.uploadFile({
        url: e.url,
        filePath: e.path[a],
        name: "upfile",
        formData: null,
        success: function(e) {
          console.log(e);
          "" != e.data ? (i++, imgArray1.push(e.data), 0 < imgArray1.length ? t.setData({
            imgArray1: imgArray1,
            edit: !0
          }) : t.setData({
            edit: !1
          }), console.log("上传商家轮播图时候提交的图片数组", imgArray1)) : wx.showToast({
            icon: "loading",
            title: "请重试"
          });
        },
        fail: function(e) {
          o++;
        },
        complete: function() {
          ++a == e.path.length ? (t.setData({
            images: e.path
          }), wx.hideToast()) : (e.i = a, e.success = i, e.fail = o, t.uploadimg(e));
        }
      });
    },
    delete: function(e) {
      console.log(e);
      var t = e.currentTarget.dataset.index;
      Array.prototype.indexOf = function(e) {
        for (var t = 0; t < this.length; t++)
          if (this[t] == e) return t;
        return -1;
      }, Array.prototype.remove = function(e) {
        var t = this.indexOf(e); -
        1 < t && this.splice(t, 1);
      }, imgArray1.remove(imgArray1[t]), this.setData({
        imgArray1: imgArray1
      });
    }
  }, "submit", function(e) {
    var t = this,
      a = imgArray1.join(","),
      i = t.data.value,
      o = t.data.user_id,
      r = t.data.seller_id,
      n = t.data.order_id;
    console.log(a), console.log(i), app.util.request({
      url: "entry/wxapp/SaveAssess",
      data: {
        user_id: o,
        img: a,
        content: i,
        order_id: n,
        seller_id: r,
        star: t.data.star,
        order_sn: t.data.order_sn
      },
      success: function(e) {
        console.log(e), 1 == e.data ? (wx.showToast({
          title: "提交成功"
        }), setTimeout(function() {
          wx.navigateBack({
            delta: 2
          });
        }, 1500)) : wx.showModal({
          title: "",
          content: "系统出差了，待会再试一下"
        });
      }
    });
  }), _defineProperty(_Page, "onReady", function() {}), _defineProperty(_Page, "onShow", function() {}),
  _defineProperty(_Page, "onHide", function() {}), _defineProperty(_Page, "onUnload", function() {
    this.setData({
      imgArray1: []
    });
  }), _defineProperty(_Page, "onPullDownRefresh", function() {}), _defineProperty(_Page, "onReachBottom", function() {}),
  _defineProperty(_Page, "onShareAppMessage", function() {}), _Page));